package io.renren.sf.controller;

import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.Map;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.renren.sf.entity.CbExpandEditionEntity;
import io.renren.sf.vo.ExpandResouceVo;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import io.renren.sf.entity.CbExpandResourceEntity;
import io.renren.sf.service.CbExpandResourceService;
import io.renren.common.utils.R;



/**
 * 
 *
 * @author cyl_txw
 * @email cyl_txw@gmail.com
 * @date 2021-08-08 13:31:02
 */
@RestController
@RequestMapping("sf/cbexpandresource")
public class CbExpandResourceController {
    @Autowired
    private CbExpandResourceService cbExpandResourceService;

    /**
     * 获取软笔扩展资源
     */
    @GetMapping("/list")
    public R list(@RequestParam Map<String, Object> params) {
        Page<CbExpandResourceEntity> list = cbExpandResourceService.getExpandResource(params);
        return R.ok().put("resourcePage", list);
    }

    @GetMapping("/getResourceAllList")
    public R getWordAllList(){
        return R.ok().put("zList", cbExpandResourceService.list());
    }

    /**
     * 信息
     */
    @GetMapping("/info/{id}")
    //@RequiresPermissions("sf:cbexpandresource:info")
    public R info(@PathVariable("id") Long id){
		CbExpandResourceEntity cbExpandResource = cbExpandResourceService.getById(id);

        return R.ok().put("cbExpandResource", cbExpandResource);
    }

    /**
     * 保存
     */
    @PostMapping("/save")
    //@RequiresPermissions("sf:cbexpandresource:save")
    public R save(@RequestBody CbExpandResourceEntity cbExpandResource){
        cbExpandResource.setCreatetime(new Date());
		cbExpandResourceService.save(cbExpandResource);
        return R.ok().put("resource", cbExpandResource);
    }

    /**
     * 修改
     */
    @PostMapping("/update")
    //@RequiresPermissions("sf:cbexpandresource:update")
    public R update(@RequestBody CbExpandResourceEntity cbExpandResource){
		cbExpandResourceService.updateById(cbExpandResource);

        return R.ok();
    }

    /**
     * 删除
     */
    @PostMapping("/delete")
    //@RequiresPermissions("sf:cbexpandresource:delete")
    public R delete(@RequestBody Long[] ids){
		cbExpandResourceService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
